﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace iLangl.Model
{
	public class ProductsResponseContext : BaseResponseContext
	{
		IList<Product> products = null;

		public override void SetContext(object context)
		{
			base.SetContext(context);



			XmlNode productsnode = document.SelectSingleNode("//Products");

			ParseExtendedInfo(productsnode);

			XmlNodeList nodes = document.SelectNodes("//Products/Product");

			products = new List<Product>();

			foreach (XmlNode node in nodes)
			{
				Product product = new Product();
				if (node.Attributes["prodId"] != null)
					product.Id = node.Attributes["prodId"].Value;
				if (node.Attributes["prodName"] != null)
					product.Name = node.Attributes["prodName"].Value;
				products.Add(product);
			}


			FireChanges();
		}

		public override object GetContext()
		{
			return products;
		}


	}
}